feat(kernel): port resilience primitives from daemon#37
Merged
stackbilt-admin merged 2 commits intomainfrom Apr 23, 2026
Merged
feat(kernel): port resilience primitives from daemon#37stackbilt-admin merged 2 commits intomainfrom
stackbilt-admin merged 2 commits intomainfrom
Conversation
Lifts resilience.ts from the daemon into core. Landing page (web/src/
landing.ts:938, :1028) promised circuit-breaker + cost-tracking to every
consumer; this wires the implementation behind the promise.
- `CircuitRegistry`, `AegisCostTracker` classes (wrap llm-providers' managers)
- `withRetry` (exponential backoff + jitter, retryable error detection)
- `withFallback` (primary → fallback with optional predicate)
- `resilient(service, op, { circuits, fallback?, retry?, circuit? })` combinator
- `markProviderExhausted` / `isProviderExhausted` (delegates to llm-providers'
defaultExhaustionRegistry — one global exhaustion state per process)
- `createResilience({ budgets, onEmergencyBudget? })` factory that returns
`{ circuits, costs, ledger }` with the ledger event listener wired inside
Monthly budgets. Those are operator-specific (daemon's $20 Anthropic / $5
Groq / $10 Cerebras ≠ anyone else's). Core exposes the factory; consumers
supply their numbers. This also keeps core's module load side-effect-free:
the ledger event listener only fires for consumers that call the factory.
This pulls @stackbilt/llm-providers in as a core dep (file: link) — which
is a first slice of #24 (Phase D adoption). Not touching cognition.ts,
groq.ts, or claude.ts call sites in this PR; those remain for #24 proper.
- core typecheck: clean
- core tests: 1474 passed, 1 skipped
- daemon typecheck against this branch: clean (PR filed separately)
- daemon tests against this branch: 1692 passed, 7 skipped
Refs: #24, #33, #35
060ee3a to
7b7526f
Compare
Core now depends on @stackbilt/llm-providers via file: link (#33). Update CI to checkout llm-providers alongside aegis-oss and build it before running npm ci in web/, matching the pattern daemon's CI uses. - Nest aegis-oss checkout under aegis-oss/ so sibling repos resolve the file:../../llm-providers path. - Build llm-providers (publishes from dist/) before core install so the file: symlink resolves types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lifts `kernel/resilience.ts` from the daemon into core. Landing page (`web/src/landing.ts:938`, `:1028`) promised circuit-breaker + cost-tracking to every consumer; this wires the implementation behind the promise. Closes #33.
What's in core now
What does NOT live in core
Monthly budgets. Those are operator-specific — daemon's `$20` Anthropic / `$5` Groq / `$10` Cerebras ≠ anyone else's. Core exposes the factory; consumers supply their numbers. This also keeps core's module load side-effect-free: the ledger event listener only fires for consumers that call the factory.
Scope note (partial #24)
This pulls `@stackbilt/llm-providers` in as a core dep (`file:` link) — which is a first slice of #24 (Phase D adoption). Not touching `cognition.ts`, `groq.ts`, or `claude.ts` call sites in this PR; those remain for #24 proper.
Design
Test plan
Refs #24, #33, #35